#ifndef COURSESEC_H_
#define COURSESEC_H_
#include <vector>
#include <string>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include "course.h"
#include <boost/date_time/posix_time/posix_time.hpp>


/// Schedule information for a course.  A course may have multiple schedules,
/// and thus multiple CourseSections.
class CourseSection {
public:

	enum SectionType { L, T, X };
	typedef std::vector< boost::posix_time::time_period > timing;

private:
	// Local typedefs, simplifies our life... a bit
	typedef std::string string;
	typedef boost::posix_time::ptime ptime;
	typedef boost::posix_time::time_period time_period;
	
public:
	CourseSection();
	~CourseSection();	
	CourseSection( const string& id,  const string& prof, const string& location, int semester_number, SectionType type, 
				   boost::weak_ptr<Course> course,
				   boost::weak_ptr<CourseSection> parent );
	
	std::string getProfessor();
	std::string getID() const;
	int getSemester();

	const timing times() const;
	void time(time_period begin_end);
	void time(ptime begin, ptime end);

	SectionType getType() const;

	std::vector<int> getTime(int) const; // int parameter specifies which time to return
	std::vector< boost::shared_ptr<CourseSection> > getSubsections() const;

	boost::weak_ptr<Course> getCourse();
	boost::weak_ptr<CourseSection> getParent();

	// Calculations
	int number_subsections();

	
private:
	// Instance variables
	// 
	// 

	std::string professor;
    std::string room;
    std::string ID;
	int semester;
	timing _time;

	// Related objects
	// A section owns its subsections but not its parents.

	boost::weak_ptr<Course> sectionOf;
	boost::weak_ptr<CourseSection> parentSection;
	std::vector< boost::shared_ptr<CourseSection> > subSections;
	SectionType sectionType; // 'L' = Lecture, 'T' = Tutorial, 'X' = Lab

	//i don't like this...
	std::vector<int> time1; // length = 2; time1[0] = start, time1[1] = end
	std::vector<int> time2; // length = 2; time2[0] = start, time2[1] = end; [*only used for lectures]


};

#endif
